package com.dinpay.plugin.d;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.NinePatch;
import android.graphics.Rect;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;

public final class j
{
  private static int a(byte[] paramArrayOfByte, int paramInt)
  {
    int i = paramArrayOfByte[(paramInt + 0)];
    int j = paramArrayOfByte[(paramInt + 1)];
    int k = paramArrayOfByte[(paramInt + 2)];
    int m = paramArrayOfByte[(paramInt + 3)];
    return i | j << 8 | k << 16 | m << 24;
  }

  public static Bitmap a(InputStream paramInputStream)
  {
    while (true)
    {
      int m;
      int n;
      label96: int i2;
      int i4;
      label110: int i11;
      label166: int i13;
      int i5;
      try
      {
        Object localObject = BitmapFactory.decodeStream(paramInputStream);
        int i = ((Bitmap)localObject).getWidth();
        int j = ((Bitmap)localObject).getHeight();
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
        int k = 0;
        if (k < 32)
        {
          localByteArrayOutputStream.write(0);
          k++;
          continue;
        }
        int[] arrayOfInt1 = new int[i - 2];
        ((Bitmap)localObject).getPixels(arrayOfInt1, 0, i, 1, 0, i - 2, 1);
        if (arrayOfInt1[0] == -16777216)
        {
          m = 1;
          if (arrayOfInt1[(-1 + arrayOfInt1.length)] != -16777216)
            break label439;
          n = 1;
          int i1 = arrayOfInt1.length;
          i2 = 0;
          int i3 = 0;
          i4 = 0;
          if (i2 < i1)
          {
            if (i3 != arrayOfInt1[i2])
            {
              i4++;
              a(localByteArrayOutputStream, i2);
              i3 = arrayOfInt1[i2];
            }
          }
          else
          {
            if (n == 0)
              break label445;
            i4++;
            a(localByteArrayOutputStream, arrayOfInt1.length);
            break label445;
            int[] arrayOfInt2 = new int[j - 2];
            ((Bitmap)localObject).getPixels(arrayOfInt2, 0, 1, 0, 1, 1, j - 2);
            if (arrayOfInt2[0] != -16777216)
              break label483;
            i8 = 1;
            if (arrayOfInt2[(-1 + arrayOfInt2.length)] != -16777216)
              break label489;
            i9 = 1;
            int i10 = arrayOfInt2.length;
            i11 = 0;
            int i12 = 0;
            i13 = 0;
            if (i11 < i10)
            {
              if (i12 == arrayOfInt2[i11])
                break label477;
              i13++;
              a(localByteArrayOutputStream, i11);
              i12 = arrayOfInt2[i11];
              break label477;
            }
            if (i9 == 0)
              break label495;
            i13++;
            a(localByteArrayOutputStream, arrayOfInt2.length);
            break label495;
            if (i15 < i7 * i14)
            {
              a(localByteArrayOutputStream, 1);
              i15++;
              continue;
            }
            byte[] arrayOfByte = localByteArrayOutputStream.toByteArray();
            arrayOfByte[0] = 1;
            arrayOfByte[1] = ((byte)i5);
            arrayOfByte[2] = ((byte)i13);
            arrayOfByte[3] = ((byte)(i14 * i7));
            a((Bitmap)localObject, arrayOfByte);
            if (NinePatch.isNinePatchChunk(arrayOfByte))
            {
              Bitmap localBitmap = Bitmap.createBitmap((Bitmap)localObject, 1, 1, -2 + ((Bitmap)localObject).getWidth(), -2 + ((Bitmap)localObject).getHeight());
              ((Bitmap)localObject).recycle();
              Field localField = localBitmap.getClass().getDeclaredField("mNinePatchChunk");
              localField.setAccessible(true);
              localField.set(localBitmap, arrayOfByte);
              localObject = localBitmap;
            }
            return localObject;
          }
        }
      }
      catch (Exception localException)
      {
        return null;
      }
      int i6;
      label439: label445: 
      do
      {
        i7 = i6;
        break label166;
        i2++;
        break label110;
        m = 0;
        break;
        n = 0;
        break label96;
        i5 = i4;
        i6 = i5 + 1;
        if (m != 0)
          i6--;
      }
      while (n == 0);
      int i7 = i6 - 1;
      continue;
      label477: i11++;
      continue;
      label483: int i8 = 0;
      continue;
      label489: int i9 = 0;
      continue;
      label495: int i14 = i13 + 1;
      if (i8 != 0)
        i14--;
      if (i9 != 0)
        i14--;
      int i15 = 0;
    }
  }

  private static void a(Bitmap paramBitmap, byte[] paramArrayOfByte)
  {
    int i = 0;
    int[] arrayOfInt1 = new int[-2 + paramBitmap.getWidth()];
    paramBitmap.getPixels(arrayOfInt1, 0, arrayOfInt1.length, 1, -1 + paramBitmap.getHeight(), arrayOfInt1.length, 1);
    int j = 0;
    int k;
    label63: int[] arrayOfInt2;
    if (j < arrayOfInt1.length)
    {
      if (-16777216 == arrayOfInt1[j])
        a(paramArrayOfByte, 12, j);
    }
    else
    {
      k = -1 + arrayOfInt1.length;
      if (k >= 0)
      {
        if (-16777216 != arrayOfInt1[k])
          break label188;
        a(paramArrayOfByte, 16, -2 + (arrayOfInt1.length - k));
      }
      arrayOfInt2 = new int[-2 + paramBitmap.getHeight()];
      paramBitmap.getPixels(arrayOfInt2, 0, 1, -1 + paramBitmap.getWidth(), 0, 1, arrayOfInt2.length);
      label121: if (i < arrayOfInt2.length)
      {
        if (-16777216 != arrayOfInt2[i])
          break label194;
        a(paramArrayOfByte, 20, i);
      }
    }
    for (int m = -1 + arrayOfInt2.length; ; m--)
      if (m >= 0)
      {
        if (-16777216 == arrayOfInt2[m])
          a(paramArrayOfByte, 24, -2 + (arrayOfInt2.length - m));
      }
      else
      {
        return;
        j++;
        break;
        label188: k--;
        break label63;
        label194: i++;
        break label121;
      }
  }

  private static void a(OutputStream paramOutputStream, int paramInt)
  {
    int i = 0xFF & paramInt >> 0;
    try
    {
      paramOutputStream.write(i);
      paramOutputStream.write(0xFF & paramInt >> 8);
      paramOutputStream.write(0xFF & paramInt >> 16);
      paramOutputStream.write(0xFF & paramInt >> 24);
      return;
    }
    catch (Exception localException)
    {
    }
  }

  private static void a(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    paramArrayOfByte[(paramInt1 + 0)] = ((byte)(paramInt2 >> 0));
    paramArrayOfByte[(paramInt1 + 1)] = ((byte)(paramInt2 >> 8));
    paramArrayOfByte[(paramInt1 + 2)] = ((byte)(paramInt2 >> 16));
    paramArrayOfByte[(paramInt1 + 3)] = ((byte)(paramInt2 >> 24));
  }

  public static void a(byte[] paramArrayOfByte, Rect paramRect)
  {
    paramRect.left = a(paramArrayOfByte, 12);
    paramRect.right = a(paramArrayOfByte, 16);
    paramRect.top = a(paramArrayOfByte, 20);
    paramRect.bottom = a(paramArrayOfByte, 24);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.dinpay.plugin.d.j
 * JD-Core Version:    0.6.2
 */